<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreatePrizesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('prizes', function (Blueprint $table) {
            $table->uuid('id', 50)->unique();
            $table->uuid('user_id', 50);
            $table->string('type_code');//类型标识符
            $table->string('name');//奖品名称
            $table->timestamp('expired_start')->nullable();//有效期
            $table->timestamp('expired_end')->nullable();
            $table->integer('stock_number');//库存
            $table->string('tag')->nullable();//奖品标签
            $table->string('background_image')->nullable();//背景图片
            $table->integer('exchange_method')->default(0);//领取方式，0现场兑换，1邮寄发放
            $table->string('exchange_address')->nullable();//领取地址
            $table->integer('voucher_type')->nullable();//券码类型，0无，1统一，2自定义
            $table->string('voucher_code')->nullable();//券码
            $table->string('voucher_link')->nullable();//自定义券码连接
            $table->string('exchange_url')->nullable();//券兑换地址
            $table->integer('resource')->nullable();//奖品来源，1自建、2购买
            $table->integer('is_valid')->default(0);//奖品是否可用，0否、1是
            $table->timestamps();
            $table->timestamp('deleted_at')->nullable();//软删除时间
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('prizes', function (Blueprint $table) {
            $table->dropIfExists();
        });
    }
}
